package com.gewu.pm.ui.activity.customer;

import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.gewu.pm.app.AppAdapter;
import com.gewu.pm.bean.ManagementBean;
import com.gewu.pm.ui.activity.base.BaseManagementActivity;
import com.gewu.pm.ui.activity.filter.FilterSalespersonActivity;
import com.gewu.pm.ui.adapter.customer.SalesPersonAdapter;

/**
 * 业务员管理
 */
public final class SalesPersonActivity extends BaseManagementActivity<ManagementBean> {

    @Override
    protected String getPageTitle() {
        return "业务员管理";
    }

    @Override
    protected String getSearchHint() {
        return "输入业务员名称";
    }

    @Override
    protected boolean showRecordCount() {
        return true;  // 显示"共X条记录"
    }

    @Override
    protected AppAdapter<ManagementBean> createAdapter() {
        return new SalesPersonAdapter(getContext());
    }

    @Override
    protected void loadData() {
        mDataList.clear();
        mDataList.add(new ManagementBean("张三"));
        mDataList.add(new ManagementBean("李四"));
        mDataList.add(new ManagementBean("王二"));
        mDataList.add(new ManagementBean("麻子"));

        // 保存原始数据用于搜索
        setOriginalData(mDataList);
        
        mAdapter.setData(mDataList);
        updateRecordCount();  // 更新"共4条记录"
        updateEmptyView();
    }

    @Override
    protected String getSearchText(ManagementBean item) {
        // 搜索业务员名称（item 左上角的文字）
        return item.getName();
    }

    @Override
    protected void onFilterClick() {
        super.onFilterClick();
    }

    @Override
    public void onItemClick(RecyclerView recyclerView, View itemView, int position) {
        ManagementBean item = mAdapter.getItem(position);
        // 跳转到业务员详情
        SalesPersonDetailsActivity.start(getActivity(), item.getName());
    }

    @Override
    public void onRightClick(View view) {
        super.onRightClick(view);
        FilterSalespersonActivity.start(this);
    }
}
